<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>添加地址·思通投研·让数据驱动投资价值!</title>
	<link href="${pageContext.request.contextPath }/img/webLogoIcon.png" rel="shortcut icon">
    <link href="${pageContext.request.contextPath }/css/bootstrap.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/css/font-awesome.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/css/custom.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/css/animate.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/css/style.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/css/datatables.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/css/datepicker3.css" rel="stylesheet">
	<link href="${pageContext.request.contextPath }/css/toastr.min.css" rel="stylesheet" />
	<link href="${pageContext.request.contextPath }/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    
    <style>
		.left{
		    float:left;
		    width:33%;
		}
		.form-horizontal{
			width: 95%;
		}
		.form-control {
			display: inline;
		}
		.col-sm-2{
			height: 50px;
		}
	</style>
</head>

<body>

    <div id="wrapper">

        <nav class="navbar-default navbar-static-side" role="navigation">
            <%request.setAttribute("LEFT", "websitelist");%>
			<%@include file="left.jsp"%>
        </nav>

        <div id="page-wrapper" class="gray-bg">
        <div class="row border-bottom">
        <jsp:include page="head.jsp" flush="true" /> 
        </div>
            <div class="row wrapper border-bottom white-bg page-heading">
                <div class="col-lg-10">
                    <h2>添加地址</h2>
                </div>
            </div>
        <div class="wrapper wrapper-content">
            <div class="ibox-content">
            	<button class="btn btn-white pull-right" onclick="window.location.href = '${pageContext.request.contextPath}/website_splist?websiteId=${websiteId}&website_name=${websitename}'" type="button">返回</button>
                <div class="table-responsive" style="margin-top: 5%;">
                	
                    <div class="panel-body">
                           <fieldset class="form-horizontal">
                               <div class="form-group"><label class="col-sm-2 control-label">网站名称:</label>
                                   <div class="col-sm-10"><input type="text" class="form-control" id="website_name" style="width: 88%;" placeholder="请输入网站名称"></div>
                               </div>
                               <div class="form-group"><label class="col-sm-2 control-label">网站地址:</label>
                                   <div class="col-sm-10"><input type="text" class="form-control" id="website_url" style="width: 88%;" placeholder="请输入网站地址"></div>
                               </div>
                           </fieldset>
                           <button class="btn btn-primary"style="margin-left: 45%;margin-top: 2%;" onclick="addWebSite()" type="button">确定添加地址</button>
                       </div>
                   </div>
                </div>
            </div>
			<jsp:include page="footer.jsp" flush="true" />
        </div>
        </div>



    <!-- Mainly scripts -->
    <script src="${pageContext.request.contextPath }/js/jquery-2.1.1.js"></script>
    <script src="${pageContext.request.contextPath }/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath }/js/jquery.metisMenu.js"></script>
    <script src="${pageContext.request.contextPath }/js/jquery.slimscroll.min.js"></script>
    <script src="${pageContext.request.contextPath }/js/jquery.jeditable.js"></script>
    <script src="${pageContext.request.contextPath }/js/datatables.min.js"></script>
    
    <!-- Peity -->
    <script src="${pageContext.request.contextPath }/js/jquery.peity.min.js"></script>

    <!-- Custom and plugin javascript -->
    <script src="${pageContext.request.contextPath }/js/inspinia.js"></script>
    <script src="${pageContext.request.contextPath }/js/pace.min.js"></script>

    <!-- Peity -->
    <script src="${pageContext.request.contextPath }/js/peity-demo.js"></script>
	<!-- toastr -->
	<script src="${pageContext.request.contextPath }/js/plugins/toastr/toastr.min.js"></script>
	<!-- Sweet alert -->
	<script src="${pageContext.request.contextPath }/js/plugins/sweetalert/sweetalert.min.js"></script>
	
    <!-- Page-Level Scripts -->
    <script>
    var websiteId = ${websiteId}
    
    function addWebSite(){
    	console.log(websiteId);	
    	if($("#website_name").val()==null||$("#website_name").val()=="")
    	{
    		toastr.error('请输入网站名称')
    		return;
    	}else if($("#website_url").val()==null||$("#website_url").val()=="")
    	{
    		toastr.error('请输入网站地址')
    		return;
    	}
    	swal({
            title: "确定添加该网站URL?",
//          text: "Your will not be able to recover this imaginary file!",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            closeOnConfirm: false,
            closeOnCancel: true },
        function (isConfirm) {
            if (isConfirm) {
                $.ajax({
            		url : "${pageContext.request.contextPath}/change/url",
            		type : "post",
            		data : {
            			urlname : $("#website_name").val(),
            			url : $("#website_url").val(),
            			websiteId : websiteId
            		},
            		success : function(res) {
            			console.log(res)
            			if (res != 500) {
            				 swal("添加成功", "该URL已添加成功", "success");
            				window.location.href = "${pageContext.request.contextPath}/website_splist?websiteId=${websiteId}&website_name=${websitename}"
            			} else {
            				swal("添加失败", "该URL添加失败", "error");
            			}
            		},
            		error : function(e) {
            			swal("添加失败", "该URL添加失败", "error");
            			window.clearInterval(timer);
            		}
            	});
            }else{
            	
            } 
        });
    	
    	
    }
    
    
  //跑马灯方法 
// 	 function init(){
// 		    //获取标题
// 		    var title=document.title;
// 		    //分割字符串--->字符数组
// 		    var arr=title.split("");
// 		    //删除第一个元素并返回该元素
// 		    var e=arr.shift();
// 		    //把一个对象添加到数组末尾
// 		    arr.push(e);
// 		    //把数组转换成字符串
// 		    var marquee=arr.join("");
// 		    //返回给浏览器
// 		    document.title=marquee;
// 		    //定时一直执行
// 		    window.setTimeout("init()",1000);
// 		}
// 		window.onload=init;
	 
    
    </script>

</body>

</html>
